//
//  JCNSButtonExtension.swift
//  JCTest3
//
//  Created by Chen on 12/10/2022.
//

import Foundation
import Cocoa

extension NSButton {
    
    public func setTitleColorAndFont(title: String, color: NSColor, fontNum: CGFloat, isBold: Bool) {
        
//        let paraStyle = NSMutableParagraphStyle()
//        paraStyle.alignment = .center
        var font = NSFont.systemFont(ofSize: fontNum)
        if isBold {
            font = NSFont.boldSystemFont(ofSize: fontNum)
        }
        let attibuteString = NSMutableAttributedString(string: title)
        attibuteString.addAttributes([.font: font, .foregroundColor: color], range: NSRange(location: 0, length: attibuteString.length))
        
        self.attributedTitle = attibuteString
        
    }
    
}
